// 云函数入口文件
const cloud = require('wx-server-sdk')
const got = require('got')
let appid = '1109781704'
let secret = 'PnJPKHvehHNoLvFj'

cloud.init()//初始化
// 云函数入口函数
exports.main = async (event, context) => {
  const {js_code}=event;
  let msgCheckUrl = `https://api.q.qq.com/sns/jscode2session?appid=${appid}&secret=${secret}&js_code=${js_code}&grant_type=authorization_code` //请求接口的链接
  let checkResponse = await got(msgCheckUrl)
  return JSON.parse(checkResponse.body)
}
